var index = 0;
var timer = setInterval(changeIndex, 2000);

function changeIndex() {
    index = index >= $('#slideBox .imgBox img').length - 1 ? 0 : index + 1;
    changeImage();
}

function changeImage() {
    $('#slideBox .imgBox img').eq(index).fadeIn('fast').siblings().fadeOut('fast');
    $('.indicators span').eq(index).addClass('current').siblings().removeClass('current');
}

$('#prev').click(function () {
    index = index <= 0 ? $('#slideBox .imgBox img').length - 1 : index - 1;
    changeImage();
})

$('#next').click(function () {
    changeIndex();
})

$('.indicators span').hover(function () {
    clearInterval(timer);
    index = $(this).index();
    changeImage();
}, function () {
    timer = setInterval(changeIndex, 2000);
})
$('.buttons div').hover(function () {
    $('.buttons div').css('opacity', '0.4');
    clearInterval(timer);
}, function () {
    $('.buttons div').css('opacity', '0');
    timer = setInterval(changeIndex, 2000);
})